var t = require("../export.js");

getApp();

Page({
    ad: {
        timerId: 0
    },
    data: {
        slideshow: [],
        slidenum: 0,
        merchantinfo: [],
        hotcat: [],
        current: 0,
        articles: [],
        options: {},
        ConfigInfo: [],
        img_url_yuyue: "http://www.ixiaochengxu.cc/resource/images/car/hall.png",
        img_url_zaixian: "http://www.ixiaochengxu.cc/resource/images/car/bespeak.png",
        img_url_shouhou: "http://www.ixiaochengxu.cc/resource/images/car/service.png",
        shareInfo: {}
    },
    onLoad: function(a) {
        var e = this;
        this.setData({
            options: a
        }), this.intslide(a), this.getMerchant(a), this.getHotCar(a), this.getArticle(a), 
        this.getConfigInfo(a), t.dg.hideShareMenu();
        var n = t.API_HOST + "/index.php/addon/DuoguanUser/Api/getShareInfo.html";
        t.requestUtil.get(n, {
            mmodule: "DuoguanCar"
        }, function(a) {
            e.setData({
                shareInfo: a
            }), t.dg.showShareMenu();
        }, this, {
            isShowLoading: !1
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.asPullDownRefresh();
    },
    onReachBottom: function() {},
    onShareAppMessage: function(t) {
        var a = this.data.shareInfo.title || "汽车";
        console.log(a);
        return {
            title: a,
            path: "/pages/car/index/index"
        };
    },
    asPullDownRefresh: function() {
        var a = this.data.options;
        this.intslide(a), this.getMerchant(a), this.getHotCar(a), this.getArticle(a), this.getConfigInfo(a), 
        t.dg.stopPullDownRefresh();
    },
    intslide: function(a) {
        var e = this;
        t.requestUtil.get(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/SlideshowApi/slideList.html", a, function(t) {
            e.setData({
                slideshow: t.img_url,
                slidenum: t.num
            });
        });
    },
    ToUrl: function(t) {
        var a = t.currentTarget.dataset.url;
        wx.navigateTo({
            url: "../webview/webview?url=" + a
        });
    },
    getMerchant: function(a) {
        var e = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getMerchant.html", a, function(t) {
            e.setData({
                merchantinfo: t
            });
        });
    },
    ToMerchant: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/pages/car/go-shop/go-shop?id= " + a
        });
    },
    goCoupon: function() {
        wx.navigateTo({
            url: "/pages/car/get-coupon/get-coupon"
        });
    },
    getArticle: function(a) {
        var e = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getArticle.html", a, function(t) {
            e.setData({
                articles: t
            }), e.startAd(t);
        });
    },
    startAd: function(t) {
        var a = this;
        clearInterval(this.ad.timerId);
        var e = 0, n = (void 0 === t.ad_interval || t.ad_interval, function() {
            var n = {};
            n.abstract = t[e].abstract, n.notice_index = e, e = e >= t.length - 1 ? 0 : e + 1, 
            a.setData({
                abstract: n.abstract
            });
        });
        this.ad.timerId = setInterval(n, 3e3), n();
    },
    getHotCar: function(a) {
        var e = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getHotCar.html", a, function(t) {
            e.setData({
                hotcar: t
            });
        });
    },
    getConfigInfo: function(a) {
        var e = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getConfigInfo.html", a, function(t) {
            e.setData({
                img_url_yuyue: t.img_url_yuyue ? t.img_url_yuyue : "http://www.ixiaochengxu.cc/resource/images/car/hall.png",
                img_url_zaixian: t.img_url_zaixian ? t.img_url_zaixian : "http://www.ixiaochengxu.cc/resource/images/car/bespeak.png",
                img_url_shouhou: t.img_url_shouhou ? t.img_url_shouhou : "http://www.ixiaochengxu.cc/resource/images/car/service.png",
                ConfigInfo: t
            });
        });
    },
    getcurrent: function(t) {
        var a = t.detail.current;
        this.setData({
            current: a
        });
    },
    callPhone: function(t) {
        var a = t.currentTarget.dataset.mobile;
        wx.makePhoneCall({
            phoneNumber: a
        });
    },
    goZhanting: function() {
        wx.navigateTo({
            url: "/pages/car/display-hall/display-hall"
        });
    },
    goZiXun: function() {
        wx.navigateTo({
            url: "/pages/car/consult/consult"
        });
    },
    gofuwu: function() {
        wx.navigateTo({
            url: "/pages/car/customer-service/customer-service"
        });
    },
    goArticle: function() {
        wx.navigateTo({
            url: "/pages/car/news/news"
        });
    },
    toCarInfo: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/pages/car/detail/detail?id=" + a
        });
    },
    goCarInfo: function(t) {
        var a = t.currentTarget.dataset.url;
        wx.navigateTo({
            url: a
        });
    }
});